Q: How do I change the font and style of the text that Mathematica generates for graphics (plots and graphs)? This includes the x- and y-axis labels, titles, tick labels, etc.\
\
A: You can take the following approaches to change fonts, font styles, and font sizes for Mathematica's graphics:\
\
\b 1. The FontForm[] object
\b0 \
You can use the
\f2\fs24 FontForm[
\i expr
\i0 , "
\i fontname
\i0 ",
\i size
\i0 ]
\f1\fs28 object to set the font and size of any given string. Normally, the
\f2\fs24 "
\i fontname
\i0 "
\f1\fs28 argument only accepts
\f2\fs24 "Bold"
\f1\fs28 ,
\f2\fs24 "Italic"
\f1\fs28 , or
\f2\fs24 "Plain"
\f1\fs28 as arguments (in other words, a style, rather than a font). If you want to change the font rather than the style, specify the actual PostScript code you would use to set a font for
\f2\i\fs24 fontname
\f1\i0\fs28 . This is done this way:\
\
\f2\fs24 "/Times-Roman findfont"
\f1\fs28 \
\
or\
\
\f2\fs24 "/Times-BoldItalic findfont"
\f1\fs28 \
\
\b\i Note:
\b0\i0 Make sure you specify the correct spelling and case for the PostScript font name (this applies to the
\f2\fs24 findfont
\f1\fs28 command as well). Otherwise, unexpected results may occur. \
\
Here's a way to find the correct font name: create some sample text in a program like Draw (
\f2\fs24 /NextDeveloper/Demos
\f1\fs28 ) and set the font and style you want to use. Copy the entire text object (not just the text) and paste it into Yap (
\f2\fs24 /NextDeveloper/Demos
\f1\fs28 ). Yap displays the actual PostScript code that creates the text. Near the end of the PostScript listing (there may be a lot of it), you'll be able to see the font name specified and how it should be referred to in the
\f2\fs24 "
\i fontname
\i0 "
\f1\fs28 parameter.\
\
Here's an example that uses FontForm[] to change the font and/or style of several elements of a graphic:\
Another way to change fonts and styles is to generate TeX output (assuming you are familiar with TeX). This is useful if you want to display the graphic in another program. To do this, use the
\f2\fs24 TeXForm[]
\f1\fs28 object. This produces straight TeX output in the Mathematica window. You can then copy and paste this output (and modify it) where needed.\
\
\b 3. The Display[]
\b0
\b object
\b0 \
You can edit the PostScript code that defines the text in the graphic. Generate a Mathematica PostScript file with the
\f2\fs24 Display["
\i file
\i0 ",
\i graphics
\i0 ]
\f1\fs28 object, where
\f2\fs24 "
\i file
\i0 "
\f1\fs28 is the name of the file to be generated, and
\f2\i\fs24 graphics
\f1\i0\fs28 is an expression that generates a graphic. The resulting Mathematica PostScript file needs to be modified. To do so, run the Shell program psfix (found in the Mathematica package) with the file you generated as an argument. You can then modify the PostScript code to change the fonts and styles of the graphic's text. The resulting file can be imported into any program that accepts .ps files.\
\
\b 4. Viewing PostScript code in Mathematica
\b0 \
Alternatively, you can also directly edit the PostScript code that defines the text from within Mathematica. You can view the PostScript code that Mathematica uses to display a graphic by selecting its cell. Choose Formatted from the Cell menu (this is a toggle which unformats the text), edit the PostScript code that defines the text, and choose Formatted again to redisplay the graphic.\